<?php

namespace App\Models;

class User extends AbstractUser
{

    /**
     * 性别: 男
     */
    const GENDER_MALA = 'male';

    /**
     * 性别: 女
     */
    const GENDER_FEMALE = 'female';

    /**
     * 表名
     *
     * @var string
     */
    protected $table = 'users';

    /**
     * 支持批量填充的字段
     *
     * @var array
     */
    protected $fillable = [
        'name', 'mobile', 'email', 'password', 'avatar'
    ];

    /**
     * 输出JSON时隐藏的字段
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token'
    ];

    /**
     * 用户信息
     *
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     */
    public function info()
    {
        return $this->hasOne(UserInfo::class, 'id');
    }

    /**
     * 账号绑定
     *
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     */
    public function binds()
    {
        return $this->hasMany(UserBinds::class);
    }

    /**
     * 普通用户
     *
     * @return bool
     */
    public function isUser()
    {
        return true;
    }
}
